//
//  SYHomeTableViewCell.m
//  songyao
//
//  Created by work on 16/10/18.
//  Copyright © 2016年 saikuo. All rights reserved.
//

#import "SYHomeTableViewCell.h"
#import "SYMedicineModel.h"

@implementation SYHomeTableViewCell {
    UIImageView *_imageView;
    UILabel *_titleLabel;
    UILabel *_contentLabel;
    UILabel *_standardLabel;
    UILabel *_moneyLabel;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _imageView = [[UIImageView alloc] init];
        _imageView.layer.borderColor = [UIColor grayBackgroundColor].CGColor;
        _imageView.layer.borderWidth = 0.5f;
        _imageView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_imageView];
        [_imageView makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(10);
            make.top.equalTo(self.mas_top).offset(2.5);
            make.size.mas_equalTo(CGSizeMake(100, 100));
        }];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont titleFont];
        _titleLabel.textColor = [UIColor grayTitleColor];
        [self.contentView addSubview:_titleLabel];
        [_titleLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_imageView.mas_right).offset(20);
            make.top.equalTo(_imageView.mas_top).offset(10);
            make.right.equalTo(self.mas_right).offset(-10);
        }];
        
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = [UIFont contentFont];
        _contentLabel.textColor = [UIColor contentColor];
        _contentLabel.numberOfLines = 2;
        [self.contentView addSubview:_contentLabel];
        [_contentLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(_titleLabel);
            make.centerY.equalTo(_imageView.mas_centerY);
        }];
        
        _moneyLabel = [[UILabel alloc] init];
        _moneyLabel.font = [UIFont contentFont];
        _moneyLabel.textColor = [UIColor redColor];
        [self.contentView addSubview:_moneyLabel];
        [_moneyLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_right).offset(-70);
            make.right.equalTo(self.mas_right).offset(-10);
            make.bottom.equalTo(_imageView.mas_bottom).offset(-10);
        }];
        
        _standardLabel = [[UILabel alloc] init];
        _standardLabel.font = [UIFont textFieldInputFont];
        _standardLabel.textColor = [UIColor contentColor];
        [self.contentView addSubview:_standardLabel];
        [_standardLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_titleLabel.mas_left);
            make.right.equalTo(_moneyLabel.mas_left).offset(-10);
            make.centerY.equalTo(_moneyLabel.mas_centerY);
        }];
    }
    return self;
}

- (void)setData:(SYMedicineModel *)data {
    _data = data;
    [_imageView sd_setImageWithURL:[NSURL URLWithString:data.headPic] placeholderImage:nil];
    _titleLabel.text = data.name;
    _contentLabel.text = data.introduction;
    _moneyLabel.text = [NSString stringWithFormat:@"¥%@",data.price];
    _standardLabel.text = [NSString stringWithFormat:@"规格：%@",data.specification];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
